﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Globalization;
using System.Web;
using System.IO;
using System.Security.Cryptography;
using System.ComponentModel;

namespace SusuCMS.Extensions
{
    public static class StringExtension
    {
        public static string Summary(this string text, int length = 100, string more = "...")
        {
            string result = text.StripHtml();
            if (result.Length < length)
            {
                return result;
            }
            else
            {
                return result.Substring(0, length) + more;
            }
        }

        public static string StripHtml(this string htmlString)
        {
            string pattern = @"<(.|\n)*?>";

            return Regex.Replace(htmlString, pattern, string.Empty);
        }
    }
}
